package io.gitee.twoke.generator.engine.impl.template.impl;

import io.gitee.twoke.generator.engine.impl.AbstractQuery;
import io.gitee.twoke.generator.engine.impl.Page;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandContext;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandExecutor;
import io.gitee.twoke.generator.engine.impl.template.TemplateFile;
import io.gitee.twoke.generator.engine.impl.template.TemplateFileQuery;
import lombok.Getter;

import java.util.List;

@Getter
public class TemplateFileQueryImpl extends AbstractQuery<TemplateFileQuery, TemplateFile> implements TemplateFileQuery {

    private String id;
    private String name;
    private String templateId;
    private List<String> groupIds;

    public TemplateFileQueryImpl(CommandContext commandContext) {
        super(commandContext);
    }

    public TemplateFileQueryImpl(CommandExecutor commandExecutor) {
        super(commandExecutor);
    }

    public TemplateFileQueryImpl(CommandExecutor commandExecutor, String databaseType) {
        super(commandExecutor);
        this.databaseType = databaseType;
    }

    public TemplateFileQueryImpl() {
    }

    @Override
    public long executeCount(CommandContext commandContext) {
        checkQueryOk();
        return commandContext.getTemplateFileEntityManager().findTemplateFileCountByQueryCriteria(this);
    }

    @Override
    public List<TemplateFile> executeList(CommandContext commandContext, Page page) {
        checkQueryOk();
        return commandContext.getTemplateFileEntityManager().findTemplateFilesByQueryCriteria(this);
    }

    @Override
    public TemplateFileQuery templateId(String templateId) {
        this.templateId = templateId;
        return this;
    }

    @Override
    public TemplateFileQuery groupIds(List<String> groupIds) {
        this.groupIds = groupIds;
        return this;
    }

    @Override
    public TemplateFileQuery name(String name) {
        this.name = name;
        return this;
    }

    @Override
    public TemplateFileQuery id(String id) {
        this.id = id;
        return this;
    }
}
